<template>
  <div>
    <el-button size="mini" @click="toadd()">添加</el-button>
    <el-table
      ref="multipleTable"
      :data="tableData"
      tooltip-effect="dark"
      style="width: 100%"
      @selection-change="handleSelectionChange">
      <el-table-column
        type="selection"
        width="55">
      </el-table-column>
      <!--    <el-table-column-->
      <!--      label="日期"-->
      <!--      width="120">-->
      <!--      <template slot-scope="scope">{{ scope.row.date }}</template>-->
      <!--    </el-table-column>-->

      <el-table-column prop="typeName" label="类型名称" show-overflow-tooltip></el-table-column>
      <el-table-column prop="typeCode" label="类型编号" show-overflow-tooltip></el-table-column>
      <el-table-column prop="levelId" label="层级" show-overflow-tooltip></el-table-column>
      <el-table-column prop="status" label="状态" show-overflow-tooltip></el-table-column>
      <el-table-column prop="parentName" label="上级类型" show-overflow-tooltip></el-table-column>

      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button
            size="mini"
            @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
          <el-button
            size="mini"
            type="danger"
            @click="handleDelete(scope.$index, scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <div class="block">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="warehouseTypeDTO.pageNum"
        :page-sizes="[5, 20, 30, 50]"
        :page-size="warehouseTypeDTO.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total">
      </el-pagination>
    </div>
  </div>

</template>

<script>
import { getList } from '../../../api/wms/type'
export default {
  name: 'index',
  data() {
    return {
      tableData: [],
      multipleSelection: [],
      warehouseTypeDTO:{
        pageNum:1,
        pageSize:4,
      },
      total:0,
    }
  },
  created() {
    this.getTable();
  },
  methods: {
    getTable(){
      getList(this.warehouseTypeDTO).then((res)=>{
        console.log(res);
        this.tableData = res.data.list;
        this.total = res.data.total;
      })
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    handleEdit(index, row) {
      this.$router.push({path:'/wms/updateindex',query:{data:row}});
    },
    handleDelete(index, row) {
      console.log(index, row);
    },
    toadd(){
      this.$router.push({path:'/wms/addindex'});
    },
    handleSizeChange(val) {
      this.warehouseTypeDTO.pageSize=val;
      this.getTable();
    },
    handleCurrentChange(val) {
      this.warehouseTypeDTO.pageNum=val;
      this.getTable();
    }
  }

}
</script>

<style scoped>

</style>
